package org.game.plugin;

import org.game.netty.server.NettyServer;

import com.jfinal.plugin.IPlugin;
import com.sojoys.artifact.constant.ConfigConstant;
import com.sojoys.artifact.manager.PropManager;

/**
 * @author : DengYing
 * @CreateDate : 2017年4月21日 下午5:32:18
 * @Description ：Please describe this document
 */
public class NettyServerPlugin implements IPlugin {
	NettyServer nettyServer = null;
	@Override
	public boolean start() {
		nettyServer = new NettyServer();
		String host = PropManager.get(ConfigConstant.SOCKET_HOST);
		int port = PropManager.getInt(ConfigConstant.SOCKET_PORT);
		try {
			nettyServer.bind(host, port, false);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

	@Override
	public boolean stop() {
		if (nettyServer!=null) {
			nettyServer.shutdown();
			return true;
		}
		return false;
	}

}
